<?php /* Smarty version 2.6.18, created on 2015-09-07 18:03:21
         compiled from operateCdk.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "top.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "left.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

<style>
.middle {
    *position:absolute;
    *top:50%;
}

</style>

<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs"><script
	type="text/javascript">
	try {
		ace.settings.check('breadcrumbs', 'fixed')
	} catch (e) {
	}
</script>

<ul class="breadcrumb">
	<li><i class="icon-home home-icon"></i> <a
		href="index.php">首页</a></li>
</ul>
<!-- .breadcrumb --></div>

<div class="page-content">

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								
								<div class="row">
									<div class="col-sm-12">
										<div class="widget-box">
											<div class="widget-header header-color-blue2">cdk操作
												<h4 class="lighter smaller"></h4>
											</div>

											<div class="widget-body">
												<div class="widget-main padding-8">
						<form class="form-horizontal" role="form">
																	
									<center>
											
										<table style="width:60%;"  id="sample-table-1" class="table table-striped table-bordered table-hover ">
										<thead>
											<tr>
												
												<th colspan="3" class="col-sm-1">
												<center>
												<strong>删除cdk</strong>
												</center>
												</th>
												
						
											</tr>
										</thead>

										<tbody>
											<tr>
											
												<th style="width:50%;">
													<label class="col-sm-6 control-label no-padding-right" for="form-field-5">CDK</label>	
												</th>	
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="Cdks" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
												<th align=center class="col-sm-1">
													<center>
													<button valign="bottom" type="button" onclick = "delCdk();" class="btn btn-info btn-success">
																删除
													</button>
													</center>
												</th>
											</tr>

										<?php if ($this->_tpl_vars['errorMsg1']): ?>											
											<tr>
												<td style="color:red" colspan="3">
													<center>
														<?php echo $this->_tpl_vars['errorMsg1']; ?>

													</center>
												</td>
											</tr>
										<?php endif; ?>	
										
										</tbody>
									</table>
									<!--  
										<div class="form-group">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-1"><strong>删除平台cdk</strong></label>
											<span>  &nbsp;</span>
										</div>
									-->	
										<table style="width:60%;"  id="sample-table-1" class="table table-striped table-bordered table-hover ">
										<thead>
											<tr>
												<th colspan="3" class="col-sm-1">
												<center>
												<strong>删除平台cdk</strong></th>
												</center>
											</tr>
										</thead>

										<tbody>
											<tr>
												<td style="width:50%;">
													<label class="col-sm-6 control-label no-padding-right" for="form-field-5">游    戏</label>	
												</td>
												<td>
												<div class="col-sm-3"><select id="selectGame1">
													<option value="" >游   戏</option>
													<?php if ($this->_tpl_vars['selectGames']): ?> <?php $_from = $this->_tpl_vars['selectGames']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
													<?php if ($this->_tpl_vars['nowGame'] == $this->_tpl_vars['value']): ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php else: ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
												</select>
												</div>
												
												</td>
												<td style="padding-top:25px;" id="middle"  rowspan=2 class="col-sm-1">
										 		<center>
													<button  type="button" onclick = "delCdkType();" class="btn btn-info btn-success">
																删除
													</button>
													</center>
										
												</td>
												
											</tr>
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">类    型</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkType1" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											
											<?php if ($this->_tpl_vars['errorMsg2']): ?>											
											<tr>
												<td style="color:red" colspan="3">
													<center>
														<?php echo $this->_tpl_vars['errorMsg2']; ?>

													</center>
												</td>
											</tr>
										<?php endif; ?>	
											
										</tbody>
							
									</table>
							<!--  
																		<div class="form-group">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-1"><strong>重置cdk</strong></label>
											<span>  &nbsp;</span>
										</div>
							-->			
										<table style="width:60%;"  id="sample-table-1" class="table table-striped table-bordered table-hover ">
										<thead>
											<tr>
												<th colspan="2" class="col-sm-1">
												<center>
												<strong>重置cdk</strong></th>
												</center>
											</tr>
										</thead>

										<tbody>
											<tr>
												<td style="width:50%;">
													<label class="col-sm-6 control-label no-padding-right" for="form-field-5">游    戏</label>	
												</td>
												<td>
													
													<div class="col-sm-3"><select id="selectGame2">
													<option value="" >游   戏</option>
													<?php if ($this->_tpl_vars['selectGames']): ?> <?php $_from = $this->_tpl_vars['selectGames']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
													<?php if ($this->_tpl_vars['nowGame'] == $this->_tpl_vars['value']): ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php else: ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
												</select>
												</div>
												
												</td>
											</tr>
											<tr>
												<td>
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">渠    道</label>
												</td>
												<td>
													
											<div class="col-sm-3">
											<select id="channel">
												<option value="" id="selectChannel">渠    道 </option>
												<?php if ($this->_tpl_vars['channel']): ?>
												<option value="<?php echo $this->_tpl_vars['channel']; ?>
" selected><?php echo $this->_tpl_vars['channel']; ?>
</option>
												<?php endif; ?> 
											</select>
											</div>
												</td>
											</tr>
											
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">类    型</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkType2" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">礼包内容</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="reward" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<td class="col-sm-4">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">开始时间</label>
												</td>
												<td class="col-sm-3">
										
										<div  class="input-group"><span  class="input-group-addon">
										 <i class="icon-calendar bigger-110"></i> </span> 
										 <input class="date-picker col-xs-3 col-sm-6" id="startTime"
												value="<?php echo $this->_tpl_vars['startDate']; ?>
" type="text" style="width:220px;" data-date-format="yyyy-mm-dd" /></div>
												</td>
											</tr>
											<td>
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">结束时间</label>
											</td>
											<td class="col-sm-3">
											<div class="input-group"><span class="input-group-addon"> 
											<i class="icon-calendar bigger-110"></i> </span> 
											<input class="date-picker col-xs-3 col-sm-6" id="endTime"
													value="<?php echo $this->_tpl_vars['endDate']; ?>
" type="text" style="width:220px;" data-date-format="yyyy-mm-dd" />
											</div>
												</td>
											</tr>
											
											<tr>
							
												<td colspan="2">
												<center>
													<button type="button" onclick = "resetCdk();" class="btn btn-info btn-success">
																重置cdk
													</button>
													</center>
												</td>
											</tr>
										
											<?php if ($this->_tpl_vars['errorMsg3']): ?>											
											<tr>
												<td style="color:red" colspan="2">
													<center>
														<?php echo $this->_tpl_vars['errorMsg3']; ?>

													</center>
												</td>
											</tr>
										<?php endif; ?>		
										</tbody>
							
									</table>
									
							</form>
							</div>
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
				</div>
				</div>
				</div>

<!-- /.table-responsive --></div>
</div>
<!-- /.page-content --></div>
<!-- /.main-content -->
<script type="text/javascript">


	jQuery(function($) {
		$('.date-picker').datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});

	});

	// 删除指定cdk
	function delCdk() {
		var cdk = $('#Cdks').val();
		if(!cdk) {
			alert("请输入要删除的cdk");
		} else {
			url = "index.php?mod=Cdk&do=deleteCdk&cdk="+cdk;
			window.location.href = url;
		}
	}
	
	// 删除指定cdk类型所有的cdk
	function delCdkType() {
		var game = $('#selectGame1').val();
		var cdkType = $('#cdkType1').val();
		if(!game || !cdkType) {
			alert("未选择游戏或未输入cdk类型!");
		} else {
			url = "index.php?mod=Cdk&do=delCdkType&game="
			+ game
			+ "&cdkType="
			+ cdkType;
			window.location.href = url;
		}
			
	}
	
	// 重置cdk
	function resetCdk() {
		var game = $('#selectGame2').val();
		var channel = $('#channel').val();
		var cdkType = $('#cdkType2').val();
		var reward = $('#reward').val();	
		var startTime = $('#startTime').val();	
		var endTime = $('#endTime').val();	
		
		if (!game || !cdkType || !reward) {
			alert("请选择游戏,填写cdk类型,礼包内容!");
		} else {
			url = "index.php?mod=Cdk&do=resetCdk&game="
				+ game
				+ "&cdkType="
				+ cdkType
				+ "&reward="
				+ reward
				+ "&channel="
				+ channel
				+ "&startTime="
				+ startTime
				+ "&endTime="
				+ endTime;
		}
		window.location.href = url;
	}
	
	function formSubmit() {
		var game = $('#selectGame').val();
		var platform = $('#platform').val();
		var channel = $('#channel').val();
		var statistics = $("input[name='form-field-radio3']:checked").val();		// 是否存储
		var startTime = $('#startTime').val();
		var endTime = $('#endTime').val();
		
		if (!game || !startTime || !endTime || (!channel && !platform)) {
			alert('请将信息填写完整！');
		} else {
			
			if(channel) {
				url = "index.php?mod=Data&do=fetchOperation&game="
					+ game
					+ "&channel="
					+ channel
					+ "&statistics="
					+ statistics
					+ "&startTime="
					+ startTime
					+ "&endTime="
					+ endTime;
			} else {
				url = "index.php?mod=Data&do=fetchOperation&game="
					+ game
					+ "&platform="
					+ platform
					+ "&statistics="
					+ statistics
					+ "&startTime="
					+ startTime
					+ "&endTime="
					+ endTime;
				
			}
			window.location.href = url;
		}
	}
	
	
	window.onload = function(){
	    var select = document.getElementById('selectGame2');
	    select.onchange = function(){
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame2  option:selected").text();
	       var _tagNum = 1;
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					
					if(dataObj == null) {
						$("#platform").empty();
						$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
						$("#channel").empty();
						$("#channel").append('<option value="" id="selectChannel">渠    道</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform").empty();
					$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
					
					var channel = dataObj.channel;
					$("#channel").empty();
					$("#channel").append('<option value="" id="selectChannel">渠    道</option>');
					for(var i=0;i<channel.length;i++){
						$("#channel").append("<option value='"+channel[i]+"' >"+channel[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	    
	} 
	
</script>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
